<link rel="stylesheet" type="text/css" href="assets/bootstrap-datepicker/css/datepicker.css" />
<aside class="lg-side">
  <div class="panel-heading tab-bg-dark-navy-blue okr-tab-head tab-right "></div>
  <div class="inbox-body mi-h8">
    <div class="row">
      <div class="col-lg-12">
        <section class="panel">
          <header class="panel-heading">
            项目目标
          </header>
          <div class="panel-body">
            <div class="form-group customerForm">
              <label class="col-sm-2 control-label">目标类型*</label>
              <div class="col-sm-10">
                <select class="form-control" id="type" onchange="change(this.value)">
                  <option value="">请选择</option>
                  <option value="XSE">销售额</option>
                  <option value="XSHK">销售回款</option>
                  <option value="FXSCS">非销售创收</option>
                  <option value="ZDGZ">重点工作</option>
                  <option value="XLTS">效率提升</option>
                  <option value="NBJS">内部建设</option>
                  <option value="QT">其他</option>
                </select>
              </div>
            </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">项目目标*</label>
                <div class="col-sm-10">
                  <textarea class="form-control" id="proTarget" onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');" maxlength="120"></textarea>
                </div>
              </div>
            <div class="form-group customerForm" id="isShow">
              <label class="col-sm-2 control-label">金额*</label>
              <div class="col-sm-10">
                <input type="text" onkeyup="clearNoNum(this)" onblur="clearNoNum(this)" min="0" class="form-control" value="0" id="money">
              </div>
            </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">目标负责人*</label>
                <div class="col-sm-10">
                  <select class="form-control" id="userId">
                    <option value="">请选择</option>
                  </select>
                </div>
              </div>
              <div class="form-group customerForm" ng-show="showFinish">
                <label class="col-sm-2 control-label">完成时间*</label>
                <div class="col-sm-10">
                  <input id="finishTime" name="finishTime" onkeyup="this.value=this.value.replace(/(^\s+)|(\s+$)/g,'');" type="text" value="" class="form-control">
                </div>
              </div>
        
            <p class="default-buttons">
              <a href="javascript:void(0);" class="button-back btn btn-info" onclick="toBack()">返回</a>
              <a href="javascript:void(0);" class="button-next  btn btn-info submit">提交</a>
            </p>
          </div>
        </section>
      </div>
    </div>
  </div>
</aside>
<script type="text/javascript" src="assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script>
    $('#finishTime').datepicker({
        format: 'yyyy-mm-dd'
    });
  function toBack() {
      toLoadHtml(1);
  };
  function change(code) {
      if (code=="XSE"||code=="XSHK"||code=="FXSCS"){
          $("#isShow").show();
      }else{
          $("#isShow").hide();
      }
  }
    change("");
  
  $certusUtils.ajax("findMemberList", {
      "proId": proId
  }, function (response) {
      var data = response.data;
      for (var i = 0; i < data.length; i++) {
          $("#userId").append("<option value='" + data[i].userId + "'>" + data[i].userName + "</option>");
      };
  });
  $(".submit").on('click',function () {
      var target = $("#proTarget").val();
      if (target==""){
          layer.msg("项目目标不能为空");
          return;
      }
      var finishTime = $("#finishTime").val();
      if (finishTime==""){
          layer.msg("完成时间不能为空");
          return;
      }
      var userId = $("#userId").val();
      if (userId==""){
          layer.msg("负责人不能为空");
          return;
      }
      var type = $("#type").val();
      if (type==""){
          layer.msg("请选择一个目标类型");
          return;
      }
      var money = $("#money").val();

      $certusUtils.ajax("addProTarget",{"projId": proId,"target":target,
          "time":finishTime,"userId":userId,"type":type,"money":money},function(){
          layer.msg("添加成功",{"time":500});
          toLoadHtml(1);
      });
  })
</script>